/**********************************************************************
 *** *                                                            * ***
 *** *  Copyright (c) 2013 Harmonia Holdings Group LLC            * ***
 *** *                                                            * ***
 *** * Permission is hereby granted to use, modify, copy, and     * ***
 *** * distribute this software and its documentation for any     * ***
 *** * purpose only without profit, provided that the above       * ***
 *** * Copyright Notice appears in all copies and that both the   * ***
 *** * Copyright Notice and this Permission Notice appears in     * ***
 *** * every copy of supporting documentation.  No title to nor   * ***
 *** * ownership of the software is transferred hereby.  The name * ***
 *** * of Harmonia Holdings Group LLC shall not be used in        * ***
 *** * advertising or publicity related to the distribution of    * ***
 *** * the software without specific, written, prior permission.  * ***
 *** * This software is provided as-delivered without expressed   * ***
 *** * or implied warranty.  Harmonia Holdings Group LLC          * ***
 *** * makes no representation about the suitability of this      * ***
 *** * software for any purpose and accepts no responsibility for * ***
 *** * its use.                                                   * ***
 *** *                                                            * ***
 *** ************************************************************** ***
 *** *                                                            * ***
 *** * This program is free software; you can redistribute it     * ***
 *** * and/or modify it under the terms of the GNU General Public * ***
 *** * License as published by the Free Software Foundation;      * ***
 *** * either version 2 of the License, or (at your option) any   * ***
 *** * later version.                                             * ***
 *** *                                                            * ***
 *** * This program is distributed in the hope that it will be    * ***
 *** * useful, but WITHOUT ANY WARRANTY; without even the implied * ***
 *** * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR    * ***
 *** * PURPOSE.  See the GNU General Public License for more      * ***
 *** * details.                                                   * ***
 *** *                                                            * ***
 *** * You should have received a copy of the GNU General Public  * ***
 *** * License along with this program; if not, write to the Free * ***
 *** * Software Foundation, Inc., 51 Franklin Street, Fifth       * ***
 *** * Floor, Boston, MA 02110-1301, USA.                         * ***
 *** *                                                            * ***
 *** * For more information: http://www.gnu.org/licenses/gpl.html * ***
 *** *                                                            * ***
 **********************************************************************/
package org.etexascode.interrep.datamodel;

import java.io.Serializable;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * ReferencePoint is a class which wraps all the data inherent in a reference point.
 * 
 * @author ablatt
 */
public class ReferencePoint implements Serializable {
	/** Serial ID. */
	private static final long serialVersionUID = 6393676216728938069L;
	
	
	/**
	 * The latitude of the reference point.
	 */
	private double latitude;
	/**
	 * The longitude of the reference point.
	 */
	private double longitude;
	
	/**
	 * Simple constructor which sets the reference point to (0, 0).
	 * (Not recommended but available)
	 */
	public ReferencePoint() {
		latitude = 0.0;
		longitude = 0.0;
	}
	
	/**
	 * Constructor which creates the reference point using the given parameters.
	 * @param latitude The latitude of the new reference point
	 * @param longitude The longitude of the new reference point
	 */
	public ReferencePoint(double latitude, double longitude) {
		this.latitude = latitude;
		this.longitude = longitude;
	}

	/**
	 * Get the latitude of the reference point
	 * @return latitude
	 */
	public double getLatitude() {
		return latitude;
	}

	/**
	 * Set the latitude of the reference point.
	 * @param latitude
	 */
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	/**
	 * Get the longitude of the reference point
	 * @return longitude
	 */
	public double getLongitude() {
		return longitude;
	}

	/**
	 * Set the longitude of the reference point.
	 * @param longitude
	 */
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	
	/**
	 * Check if object is the same as this.
	 * @param object The object to test against.
	 * @return If the values are equal.
	 */
	@Override
	public boolean equals(Object object) {
		if(object instanceof ReferencePoint) {
			ReferencePoint rp = (ReferencePoint) object;
			
			if(this.latitude != rp.getLatitude()){
				return false;
			}
			if(this.longitude != rp.getLongitude()){
				return false;
			}
			return true;
		} else {
			return false;
		}
	}

	/**
	 * HashCode operation. 
	 * @return A hashcode of the data. 
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(7, 71).
				append(latitude).
				append(longitude).
				toHashCode();
	}
}
